package com.cy.pj.common.util;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

import javax.servlet.http.HttpServletRequest;

/**
 * @DATE: 2021/3/12 14:48
 * @Author: LuckyH
 */
public class PagUtil {
    // 启动分页查询
    public static <T> Page<T> startPage(){
        // 获取请求对象
        HttpServletRequest request = ServletUtil.getRequest();
        // 获取请求参数对象
        String pageSizeStr = request.getParameter("pageSize");

        String pageCurrentStr = request.getParameter("pageCurrent");

        int pageCurrent = StringUtil.isEmpty(pageCurrentStr) ? 1 : Integer.parseInt(pageCurrentStr);

        int pageSize = StringUtil.isEmpty(pageSizeStr) ? 10 : Integer.parseInt(pageSizeStr);

        return PageHelper.startPage(pageCurrent,pageSize);
    }
}
